/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ps.yj.y1j0.rest;

import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.jboss.resteasy.annotations.Form;
import org.jboss.resteasy.annotations.cache.NoCache;
import ps.yj.y1j0.business.KVData.YJKVDataHandler;
import ps.yj.y1j0.business.KVData.YJKVDataObject;
import ps.yj.y1j0.business.YJDataHandler;
import ps.yj.y1j0.data.YJResult;

import java.sql.SQLException;

/**
 * @author yanjun
 */
@Path("/put")
@NoCache
public class YJRestPut {
    @PUT
    @Path("/kv")
    @Produces(MediaType.APPLICATION_JSON)
    public YJResult updateKVData(@Form YJKVDataObject data) {
        YJResult resultData = new YJResult();
        YJDataHandler handler = new YJKVDataHandler(data.getDataKind(), "rowid");
        int result = handler.update(data);
        resultData.setStatus(result > 0 ? Boolean.TRUE : Boolean.FALSE);
        resultData.setMessage(result > 0 ? "修改成功！" : "修改失败！");
        return resultData;
    }
}
